OPTIONS LINESIZE=87;
TITLE 'ec';

/**** 
JUNE 2008 
****/

libname lib8 'C:\Documents and Settings\user1\My Documents\bigfiles\ec8';
libname lib7 'C:\Documents and Settings\user1\My Documents\bigfiles\ec7';
libname libs 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\research\att\formation\EC\writing\qjep\sasfiles';

libname lib 'D:\Users\baranany\Dropbox\work\research\att\formation\EC\ec678\ec';

/**
STUDY 1
**/
/*READ EXPLICIT*/
data eds; set lib7.explicitec1000000;run;
proc freq data=eds; tables QUESTIONNAIRE_NAME_S; run;
proc freq data=eds; tables QUESTION_NAME_S; run;
data eExp; set eds;
if QUESTION_NAME_S not in ("feedback" "text" "openreason" "IMPTASKTO");
qst = QUESTION_NAME_S;
expR = INPUT(QUESTION_RESPONSE_S, 4.0); 

subject=SESSION_ID; 
qstN = QUESTION_NUMBER;

if index(QUESTIONNAIRE_NAME_S,"ec") > 0 then do;
	if QUESTION_NAME_S = "feedback" then qst = "ecfb";
	ecc = substr(QUESTIONNAIRE_NAME_S, 5);
	if ecc="a" then ec=1; else if ecc="b" then ec=2; 
	_ecN = substr(QUESTIONNAIRE_NAME_S, 3, 1);
	ecN = input(_ecN, 4.0);
end;
keep subject TASK_NUMBER SESSION_ID qst qstN expR ec ecn; run;

PROC TRANSPOSE DATA=eExp OUT=qds; VAR expR;BY subject;ID qst;RUN; 
data qds; set qds; drop _NAME_;run;
/*proc print data=qds;run;*/
proc contents data=qds;run;

data qds; set qds;djigrur = ecjigglypuff-ecruriri;run;
PROC MEANS DATA=qds n MEAN MAXDEC=2 fw=7 std stderr;VAR djigrur prfP;RUN;
data lib7.qds; set qds; run;

*save EC condition;
PROC MEANS noprint DATA=eExp n MEAN MAXDEC=2 fw=7 std stderr; VAR ec;CLASS subject;output out=cnds mean=cond;RUN;
data cnds; set cnds; keep subject cond; run;
/*proc print data=cnds;run;*/
proc freq data=cnds; tables cond; run;
data lib7.cnds; set cnds; run;

*save EC N pairing;
PROC MEANS noprint DATA=eExp n MEAN MAXDEC=2 fw=7 std stderr;VAR ecN;CLASS subject;output out=ecN mean=ecN;RUN;
data ecn; set ecn; keep subject ecn; run; 
proc freq data=ecn; tables ecn; run;
data lib7.ecn; set ecn; run;

data ecfb; set eds; 
if index(QUESTIONNAIRE_NAME_S,"ec") > 0 and QUESTION_NAME_S = "feedback";
nCorrects = substr(QUESTION_RESPONSE_S,9,2);
nCorrect = input(nCorrects, 4.0);
nFalses = substr(QUESTION_RESPONSE_S,index(QUESTION_RESPONSE_S, "s,") + 2,3);
nFalse=  input(nFalses, 4.0);
subject=session_id;
keep nCorrect nFalse subject session_id;
run;
proc freq data=ecfb; tables nCorrect; run;
data lib7.ecfb; set ecfb; run;

*****************************;
*add data from registration;
data demo; set lib7.demoec; run;
proc sort data=demo; by USER_ID;run;
proc transpose data=demo name=name out=demoDS; by USER_ID; var VALUE_S;id CHARACTERISTIC_S;
proc print data=demoDS;run;
proc freq data=demods; tables zipcode; run;
data demoDS; set demoDS; 
format dPlt 2.;
dPlt = politicalid;
age = 2007-input(birthyear,4.0);
orgn = citizenship;
race='.....';
if raceomb=1 then race='ntvAm';
if raceomb=2 then race='eAsia';
if raceomb=3 then race='sAsia';
if raceomb=4 then race='natPc';
if raceomb=5 then race='black';
if raceomb=6 then race='white';
if raceomb=7 then race='blkwh';
if raceomb=8 then race='mixed';
if raceomb=9 then race='unkno';
sex = substr(sex, 1,1);
sx = '.';
sx = sex;
keep dPlt sex sx age orgn race USER_ID;run;
proc print data=demoDS;run;
*merge with session data;
data ssds; set lib7.sessiontaskec1000000; run;
PROC SORT DATA=ssds; BY SESSION_ID; RUN;
PROC TRANSPOSE DATA=ssds OUT=tss PREFIX=s;VAR USER_ID;BY SESSION_ID; RUN;
data tss; set tss; USER_ID = s1; keep SESSION_ID USER_ID; run;
proc print data=tss;run;
PROC SORT DATA=demoDS; BY USER_ID; RUN;
PROC SORT DATA=tss; BY USER_ID; RUN;
data demoDS; merge demoDS tss; by USER_ID; drop _NAME_; run;
data demoDS; set demoDS; where SESSION_ID > 0; subject = SESSION_ID; run;
proc print data=demoDS;run;
data lib7.demoDS; set demoDS;run;

data ssds; set ssds; subject = SESSION_ID;run;

/*Read duration*/
data startT; set ssds; if TASK_ID_S = "con"; startT = TASK_CREATION_DATE; run;
data endT; set ssds; if TASK_ID_S = "dbrf"; endT = TASK_CREATION_DATE; run;
PROC SORT DATA=startT; BY SESSION_ID; RUN;
PROC SORT DATA=endT; BY SESSION_ID; RUN;
data timeds; merge startT endT; by SESSION_ID; duration = endT - startT;run;
proc freq data=timeds; tables duration; run;
data lib7.timeds; set timeds;run;

/*read order*/
PROC SORT DATA=ssds; BY subject TASK_ID_S;RUN;
PROC UNIVARIATE DATA=ssds NOPRINT;
VAR TASK_NUMBER;OUTPUT OUT=usession mean=mNum mode=tNum;BY subject TASK_ID_S;RUN;
PROC TRANSPOSE DATA=usession OUT=orderDS prefix=ord;VAR TASK_ID_S;ID tNum;BY subject;RUN;
proc freq data=orderDS; tables ord3; run;
PROC SORT DATA=orderds; BY ord3; RUN;
proc freq data=orderDS; tables ord10; by ord3; run;
proc freq data=orderDS; tables tOrd; run;
data lib7.orderDS; set orderDS; run;

/*read ec trials*/
data ds; set lib7.iatec1000000; subject=session_id;run;

PROC SORT DATA=ds; BY subject; RUN;PROC SORT DATA=ecn; BY subject; RUN;
data checkEC; merge ds ecn; by subject;run;

data checkEC; set checkEC;
char='F';
if index(trial_name_s, "jigg") > 0 then char='j';
else if index(trial_name_s, "rur") > 0 then char='r';
else if index(trial_name_s, "dig") > 0 then char='d';
cs=0; target=0;
if char in ('j' 'r') then CS=1;
else if char='d' then target=1;

if char='F' then filler=1; else filler=0;

nat = 'X';
if index(trial_name_s, "nat") > 0 then val='t';

run;

*for filler;
PROC MEANS DATA=checkEC n MEAN noprint MAXDEC=2 fw=7 std stderr; VAR filler; CLASS ecn subject; output out=countF; RUN;
/*proc print data=countF;run;*/
PROC SORT DATA=countF; BY subject; RUN;
PROC TRANSPOSE DATA=countF OUT=tcountF; Id _stat_; VAR filler; BY subject; copy ecn; where _TYPE_ = 3; RUN;
data tcountf; set tcountf; if _NAME_="filler"; ftrials = mean*n; run;
*for cs;
PROC MEANS DATA=checkEC noprint n MEAN MAXDEC=2 fw=7 std stderr; VAR cs; CLASS ecn subject; output out=countc; RUN;
PROC SORT DATA=countc; BY subject; RUN;
PROC TRANSPOSE DATA=countc OUT=tcountc; Id _stat_; VAR cs; BY subject; copy ecn; where _TYPE_ = 3; RUN;
data tcountc; set tcountc; if _NAME_="cs"; cstrials = mean*n; run;
*for target;
PROC MEANS DATA=checkEC noprint n MEAN MAXDEC=2 fw=7 std stderr; VAR target; CLASS ecn subject; output out=countt; RUN;
PROC SORT DATA=countt; BY subject; RUN;
PROC TRANSPOSE DATA=countt OUT=tcountt; Id _stat_; VAR target; BY subject; copy ecn; where _TYPE_ = 3; RUN;
data tcountt; set tcountt; if _NAME_="target"; ttrials = mean*n; run;

data tcountf; set tcountf; fillerM = mean; keep subject ecn fillerM ftrials; run;
data tcountt; set tcountt; trgtM = mean; keep subject ecn trgtM ttrials; run;
data tcountc; set tcountc; csM = mean; ntrials = n; keep subject ecn csM cstrials ntrials; run;

PROC SORT DATA=tcountf; BY subject; RUN;PROC SORT DATA=tcountt; BY subject; RUN; PROC SORT DATA=tcountc; BY subject; RUN;
data cntec; merge tcountf tcountt tcountc; by subject; run;
PROC MEANS DATA=cntec n MEAN MAXDEC=2 fw=7 std stderr;VAR ntrials fillerM trgtM csM;CLASS ecn;RUN;
data lib7.cntec; set cntec; run;

/*merge all*/
data qds; set lib7.qds; if session_id ^= . then subject=session_id; run;
data cnds; set lib7.cnds; if session_id ^= . then subject=session_id; run;
data ecn; set lib7.ecn; if session_id ^= . then subject=session_id; run;
data ecfb; set lib7.ecfb; if session_id ^= . then subject=session_id; run;
data demoDS; set lib7.demoDS; if session_id ^= . then subject=session_id; run;
data timeds; set lib7.timeds; if session_id ^= . then subject=session_id; run;
data cntec; set lib7.cntec; if session_id ^= . then subject=session_id; run;

*merge with all data;
PROC SORT DATA=qds; BY subject; RUN;
PROC SORT DATA=cnds; BY subject; RUN;
PROC SORT DATA=ecn; BY subject; RUN;
PROC SORT DATA=ecfb; BY subject; RUN;
PROC SORT DATA=demoDS; BY subject; RUN;
PROC SORT DATA=timeds; BY subject; RUN;
PROC SORT DATA=cntec; BY subject; RUN;

data allds; merge ecn ecfb qds cnds demoDS timeds cntec; by subject; run;

data allds1; set allds; 
if ecn=1 then ecn=12; else if ecn=2 then ecn=22; else if ecn=3 then ecn=32;
if cond=1 then pos = "jig"; else if cond=2 then pos = "rur";
aprf = abs(djigrur);aatt = mean(abs(ecruriri-4), abs(ecjigglypuff-4));
if ncorrect > 14 and nFalse < 7 and ttrials=22 and djigrur not in (.) then ok =1; else ok=0;
if pos = "jig" then dposneg = djigrur; else if pos = "rur" then dposneg = djigrur*-1; 
if posm < 0 then posm = posm + .5; else if posm > 0 then posm = posm - .5;
if negm < 0 then negm = negm + .5; else if negm > 0 then negm = negm - .5;
if pos = "jig" then do
	ECpos = ecjigglypuff; ECneg = ecruriri;
	mpos = posm; mneg=negm*-1;
end;
else if pos = "rur" then do
	ECneg = ecjigglypuff; ECpos = ecruriri;
	mpos = posm*-1; mneg=negm;
end;
new_macc = mean(mpos, mneg);
mjigpos = negm*-1 + posm;
mjigrur = posm-negm;
certainty = mean(abs(posm), abs(negm));
certaintyF = mean(abs(posfm), abs(negfm));
memused=new_macc*used;
memdemand=new_macc*demand;
new_maccused = new_macc*used; new_maccXecn = new_macc*ecn; 
new_maccXusedXecn = new_macc*used*ecn; usedXecn = used*ecn;
new_maccdm = new_macc*demand; 
new_maccXecn = new_macc*ecn;
if (posm ne .) and (negm ne .) and (djigrur ne .) and (used ne .) and (demand ne .) and (paired ne .) then rspall=1;
if ok=1 and rspall=1 then include=1;
ec = ecn>0;
run;


proc freq data=allds1; tables include; run;
proc freq data=allds1; tables sex; where include=1; run;
/*Overall effect*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1;RUN;
/*by number of trials*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;class ecn; where include=1;RUN;
/*noticed*/
proc freq data=allds1; tables paired / missing; where include=1 and ecn >0;run;
proc freq data=allds1; tables paired*ec / chisq; where include=1;run;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;CLASS paired;where include=1;RUN;
/*memory*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc;where include=1;RUN;
PROC GLM DATA=allds1;class ecn; MODEL new_macc = ecn / SS3; where include=1;RUN;
/*memory-attitude corr*/
proc corr data=allds1;  var new_macc dposneg;where include=1;RUN;run;
PROC reg DATA=allds1;MODEL dposneg = new_macc ecn new_maccXecn / stb;where include=1; run;
/*used*/
proc freq data=allds1; tables used; where include=1 and ecn>0;run;
PROC SORT DATA=allds1; BY used; RUN;
proc corr data=allds1;var new_macc; with dposneg; by used;where include=1 and ecn>0;run;
PROC reg DATA=allds1;MODEL dposneg = new_macc used new_maccused / stb;where include=1 and ecn>0;run;
proc corr data=allds1;var new_macc; with dposneg; where include=1 and ecn>0 and used<0;run;
proc corr data=allds1;var new_macc; with dposneg; where include=1 and ecn>0 and used>=0;run;
proc corr data=allds1;  var dposneg; with used; partial new_macc; where include=1;run;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and used<0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and used>0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and used<0 and new_macc>0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and used>0 and new_macc>0;RUN;
/*demand*/
proc freq data=allds1; tables demand; where include=1 and ecn>0;run;
proc corr data=allds1;var new_macc; with dposneg; where include=1 and ecn>0 and demand<0;run;
proc corr data=allds1;var new_macc; with dposneg; where include=1 and ecn>0 and demand>0;run;
PROC reg DATA=allds1;MODEL dposneg = new_macc demand memdemand / stb;where include=1 and ecn>0;run;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and demand<0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and demand<0 and new_macc>0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and demand>0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1 and demand>0 and new_macc>0;RUN;
/*demand and used*/
proc corr data=allds1;  var used; with demand;where include=1; run;
PROC reg DATA=allds1;MODEL dposneg = used / stb;where include=1 and demand=-3 and ecn>0;run;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR dposneg; where include=1 and demand=-3 and ecn>0 and used<0; RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR dposneg; where include=1 and demand=-3 and ecn>0 and used>=0; RUN;
/*false contingency memory*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderrt t prt;VAR djigrur;where include=1 and ecn=0;RUN;
proc corr data=allds1;  var djigrur; with mjigpos;where include=1 and ecn=0;run;
proc corr data=allds1;  var djigrur; with mjigpos;where include=1 and ecn=0 and certainty>=1;run;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderrt t prt;VAR mjigpos;where include=1 and ecn=0 and certainty>=1;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderrt;VAR new_macc certainty; class pos; where include=1;RUN;
proc ttest data=allds1;class pos;var new_macc;class pos; where include=1;RUN;
/*reverse*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR new_macc;where include=1 and dposneg<0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR dposneg;where include=1 and new_macc<0;RUN;
PROC GLM DATA=allds1; class ecn; MODEL dposneg = ecn / ss3; where include=1 and new_macc<0;RUN;
/*memory without EC*/
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR new_macc;where include=1 and dposneg<=0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 std stderr t prt;VAR new_macc;where include=1 and dposneg<=0;RUN;
PROC MEANS DATA=allds1 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; where include=1 and dposneg<=0 and certainty>1; RUN;

/***STUDY 2***/
data allds2; set allds2; 
aprf = abs(djigrur);aatt = mean(abs(ecruriri-4), abs(ecjigglypuff-4));

if mecbulbasaur < 0 then mecbulbasaur = mecbulbasaur + .5; 
else if mecbulbasaur > 0 then mecbulbasaur = mecbulbasaur - .5;
if mecharmander < 0 then mecharmander = mecharmander + .5; 
else if mecharmander > 0 then mecharmander = mecharmander - .5;
if meckakuna < 0 then meckakuna = meckakuna + .5; 
else if meckakuna > 0 then meckakuna = meckakuna - .5;
if ncorrect > 14 and nFalse < 7 and ttrials=22 and zdjigrur not in (.) then ok =1; else ok=0;
if pos = "jig" then dposneg = djigrur; else if pos = "rur" then dposneg = djigrur*-1; 
if mecruriri < 0 then mecruriri = mecruriri + .5; 
else if mecruriri > 0 then mecruriri = mecruriri - .5;
if mecjigglypuff < 0 then mecjigglypuff = mecjigglypuff + .5; 
else if mecjigglypuff > 0 then mecjigglypuff = mecjigglypuff - .5;

mjigrur = mecjigglypuff-mecruriri;

if pos = "jig" then do
	ECpos = ecjigglypuff; ECneg = ecruriri;
	mpos = mecjigglypuff; mneg=mecruriri*-1;
end;
else if pos = "rur" then do
	ECneg = ecjigglypuff; ECpos = ecruriri;
	mpos = mecjigglypuff*-1; mneg=mecruriri;
end;
new_macc = mean(mpos, mneg);

memused=mdjigrur*used;memdemand=mdjigrur*demand;
new_maccused = new_macc*used; 
new_maccdm = new_macc*demand; 
mpnused=new_macc*used;mpndemand=new_macc*demand; 
new_maccXusedXecn = new_macc*used*ecn;usedXecn =used*ecn;
pairedXecn = paired*ecn;
new_maccXecn = new_macc*ecn;

ebulbasaur = ecbulbasaur-4; 
echarmander=eccharmander-4;
ekakuna=eckakuna-4;

if (mecruriri ne .) and (mecjigglypuff ne .) and (djigrur ne .) and (used ne .) and (demand ne .) and (paired ne .) then rspall=1;
if ok=1 and rspall=1 then include=1;

run;

/*basics*/
proc freq data=allds2; tables include; run;
proc freq data=allds2; tables sex; where include=1; run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev lclm uclm;VAR age;where include=1; run;
/*ec*/
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg;where include=1;RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; class ecn; where include=1; RUN;
PROC reg DATA=allds2;MODEL dposneg = ecn / stb;where include=1;run;
/*awareness*/
proc freq data=allds2; tables paired / missing; where include=1;run;
PROC reg DATA=allds2;MODEL dposneg = paired / stb;where include=1;run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; class PAIRED; where include=1; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where include=1 and paired<=1; RUN;
/*memory*/
proc freq data=allds2; tables new_macc / missing; where include=1;run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; class ecn; where include=1; RUN;
PROC reg DATA=allds2;MODEL new_macc = ecn / stb;where include=1;run;
PROC reg DATA=allds2;MODEL dposneg = ecn / stb;where include=1 and new_macc>0;run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; class ecn; where include=1 and new_macc>0; RUN;
proc corr data=allds2;  var dposneg; with new_macc; where include=1; run;
/*reported used*/
proc freq data=allds2; tables used; run;
PROC reg DATA=allds2;MODEL dposneg = new_macc used new_maccused / stb;where include=1;run;
PROC reg DATA=allds2;MODEL dposneg = new_macc used new_maccused new_maccXusedXecn / stb;where include=1;run;
PROC SORT DATA=allds2; BY ecn; RUN;
PROC reg DATA=allds2;MODEL dposneg = new_macc used new_maccused / stb;where include=1; by ecn; run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where include=1 and ecn=12 and used<0; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where include=1 and ecn=12 and used>0; RUN;
/*demand*/
proc freq data=allds2; tables demand; where include=1; run;
proc corr data=allds2;  var dposneg; with new_macc; where include=1 and demand<0; run;
proc corr data=allds2;  var dposneg; with new_macc; where include=1 and demand>0; run;
PROC reg DATA=allds2;MODEL dposneg = new_macc demand new_maccdm / stb;where include=1; run;
PROC reg DATA=allds2;MODEL dposneg = new_macc demand new_maccdm / stb;where include=1 and ecn>4; run;
/*used without demand*/
PROC reg DATA=allds2;MODEL dposneg = used / stb;where include=1 and demand=-3;run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where include=1 and demand=-3 and used<0; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where demand=-3 and used>=0; RUN;
/*false memory*/
proc corr data=allds2;
  var mecbulbasaur meccharmander meckakuna mecruriri mecjigglypuff;
  with ecbulbasaur eccharmander eckakuna ecruriri ecjigglypuff;
  where include=1;run;
proc corr data=allds2;
  var exbulbasaur excharmander exkakuna exjigglypuff exruriri;
  with cbulbasaur ccharmander ckakuna cjigglypuff cruriri;
  where include=1;run;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;
VAR mecbulbasaur meccharmander meckakuna; where include=1; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;
VAR ecruriri ecjigglypuff mecruriri mecjigglypuff; where include=1; RUN;
/*reverse */
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; where include=1 and dposneg<=0; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; where include=1 and dposneg<0 and ecn=12; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; where include=1 and dposneg<0 and ecn=4; RUN;
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR new_macc; where include=1 and dposneg<0 and ecn=8; RUN;
/*reverse EC*/
PROC MEANS DATA=allds2 n MEAN MAXDEC=2 fw=7 stderr stddev t prt;VAR dposneg; where include=1 and new_macc<=0; RUN;

